Skip to content

feat(opencode): add killswitch indicators to quota toast#38

Open
iceteaSA wants to merge 5 commits into
cortexkit:mainfrom
iceteaSA:feat/killswitch-toast
Open

feat(opencode): add killswitch indicators to quota toast#38
iceteaSA wants to merge 5 commits into
cortexkit:mainfrom
iceteaSA:feat/killswitch-toast

Conversation

@iceteaSA
Copy link
Copy Markdown
Contributor

@iceteaSA iceteaSA commented May 21, 2026

Dependencies: Requires #35 (killswitch) and #36 (quota-toast) to be merged first.

Adds killswitch awareness to quota toast notifications:

  • 🔴 red dot for killed accounts
  • 🟢 green dot for active/routable accounts
  • Killswitch-aware active account selection skips killed accounts

Single file change: packages/opencode/src/index.ts


Summary by cubic

Adds killswitch-aware quota toasts with red/green indicators and blocks low‑quota accounts with a synthetic 429 and Retry‑After. Introduces a shared QuotaManager with inflight dedupe, exponential backoff, cross-process guards, persistence, and request-count refresh; quota usage toasts auto‑show after refresh.

  • New Features

    • Quota toast: red/green state dots, usage bars, reset times, and severity; auto-shown after quota refresh.
    • Killswitch routing: per-account thresholds (5h/7d), eager refresh on first request, skip killed accounts in main/fallback selection; synthetic 429 with Retry-After from earliest reset; /claude-killswitch to check status, toggle, set thresholds, and show usage.
    • QuotaManager: unified cache for main + fallbacks with inflight dedupe, persisted 429/5xx backoff, cross-process file lock, seeded from storage, and refreshEveryNRequests support.
  • Refactors

    • packages/core: new killswitch and quota-manager modules; FallbackAccountManager now uses QuotaManager for shared staleness/refresh.
    • packages/opencode: routing and quota toast now read from QuotaManager; honors request-count-based refresh and killswitch state.

Written for commit b6cc376. Summary will update on new commits. Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 10 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Fix all with cubic | Re-trigger cubic

Comment thread packages/core/src/quota-manager.ts
@iceteaSA iceteaSA force-pushed the feat/killswitch-toast branch 3 times, most recently from 91d7971 to bbb2424 Compare May 22, 2026 16:52
Unified quota cache and API gateway for main + fallback quota state.
All consumers share one QuotaManager instance for consistent caching.

Features:
- Inflight deduplication prevents concurrent API calls
- Exponential backoff (60s-15min) for 429/5xx errors
- Persists main quota and backoff state to disk via callbacks
- Cross-process file lock guard for quota API dedup
- Seeds from persisted storage on construction
- Integrates with FallbackAccountManager for shared staleness
- Captures storage path at init to prevent test config corruption
- Request-count-based refresh trigger (refreshEveryNRequests)
@iceteaSA iceteaSA force-pushed the feat/killswitch-toast branch from bbb2424 to 16c1a8b Compare May 22, 2026 16:58
iceteaSA added 4 commits May 22, 2026 19:07
Displays quota usage bar notifications via client.tui.showToast after
quota data is refreshed. Shows main and fallback account usage with
visual bars, percentage, and reset time. Toast variant reflects
severity (info < 70%, warning >= 70%, error >= 90%).
…reshold

Per-account request blocking when remaining quota drops below configurable
thresholds. Returns synthetic 429 when all accounts (main + fallbacks) are
below their thresholds. Includes /claude-killswitch slash command for
runtime management.

Features:
- Per-account threshold overrides (5h and 7d windows)
- Eager quota refresh on first request for killswitch evaluation
- Skip-main routing when main is killed (try surviving fallbacks)
- Filter killed accounts from reactive fallback path
- Retry-After header with earliest quota reset time
Shows red dot for killed accounts and green dot for active accounts
in quota toast notifications. Killswitch-aware active account selection
skips killed accounts when determining the routable account.
@iceteaSA iceteaSA force-pushed the feat/killswitch-toast branch from 16c1a8b to b6cc376 Compare May 22, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant